<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/page/include/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="${ctx }/layui/css/layui.css">
    <link rel="stylesheet" href="${ctx }/css/style.css">
    <script>
        var ctx = "${ctx}";
    </script>
    <title>登录</title>
    <style>
        body {
            margin: 0;
        }

        #video {
            position: fixed;
            right: 0;
            bottom: 0;
            width: auto;
            height: auto;
            z-index: -1;
            -webkit-filter: grayscale(80%);
        }
    </style>
</head>
<body class="login-main1">
<video id="v1" autoplay loop muted>
    <source src="${ctx }/image/vid_header2.mp4" type="video/mp4"/>
</video>
<div class="login-main">
    <header class="layui-elip">登 录</header>
    <form class="layui-form" method="post" lay-filter="login">
        <div class="layui-input-inline">
            <input id="username" name="username" value="" type="text" placeholder="请输入用户名" class="layui-input">
        </div>
        <div class="layui-input-inline">
            <input id="password" name="password" value="" type="password" placeholder="请输入密码" class="layui-input">
        </div>
        <div class="layui-input-inline">
            <button id="loginBt" class="layui-btn">登录</button>
            <%--            <input type="submit" value="登录" class="layui-btn">--%>
        </div>
        <div class="layui-input-inline">
            <span id="registerId" style="cursor:pointer">注冊</span>
            <%--            <input type="submit" value="登录" class="layui-btn">--%>
        </div>
    </form>

</div>
<script type="text/javascript">
    $(document).ready(function () {

    });
    //登陆
    $(function () {
        $('#loginBt').on('click', function () {
            var username = $('#username').val();
            var password = $('#password').val();
            if ("" == username) {
                alert("请输入用户名！");
                return false;
            } else if ("" == password) {
                alert("请输入密码！");
                return false;
            }
            var i;
            $.ajax({
                type: "post",
                url: ctx + "/login",
                data: {
                    username: username,
                    password: password
                },
                success: function (result) {
                    if (result.code == 0) {
                        parent.location.href = ctx + '/index';
                    } else if (result.code != 0) {
                        alert(result.msg);
                        $("#password").val('');
                    }
                },
                error: function () {
                    alert("获取数据失败！");
                }
            });
            return false;
        });
        //跳转注册页面
        $('#registerId').on('click', function () {
            parent.location.href = ctx + '/jsp/user/registerUser.jsp';
        });
    });
</script>
</body>
</html>